dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.form.Button");
dojo.require("dijit.Menu");
dojo.require("dijit.form.DropDownButton");
dojo.require("dijit.Toolbar");
dojo.require("dijit.TooltipDialog");
dojo.require("dijit.form.TextBox");
dojo.require("esri.map");
    
      
      
/**** GLOBAL OBJECT ****/      
var _g = {
	map: null,
	streeturl: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer",
	topourl: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer",
	saturl: "http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer",
	currentBaseMap: null
}

function init() {
    var initExtent = new esri.geometry.Extent({"xmin":-16960931,"ymin":2407763,"xmax":-4437489,"ymax":7837849,"spatialReference":{"wkid":102100}});
	_g.map = new esri.Map("map",{extent:initExtent});
	//Add the world street map layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&f=typekeywords:service    
	var basemap = new esri.layers.ArcGISTiledMapServiceLayer(_g.streeturl, {id:"street"});
	_g.map.addLayer(basemap);
	_g.currentBaseMap = "street";
	//resize the map when the browser resizes - view the 'Resizing and repositioning the map' section in
	//the following help topic for more details http://helpdev.esri.com/EN/webapi/javascript/arcgis/help/jshelp_start.htm#jshelp/inside_guidelines.htm
	var resizeTimer;
	dojo.connect(_g.map, 'onLoad', function(theMap) {
	  dojo.connect(dijit.byId('map'), 'resize', function() {  //resize the map if the div is resized
	        clearTimeout(resizeTimer);
	        resizeTimer = setTimeout( function() {
	          _g.map.resize();
	          _g.map.reposition();
	        }, 500);
	      });
	    });
}



dojo.addOnLoad(init);